package com.flymobi.admin;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.flymobi.po.Manager;
import com.flymobi.util.WebContext;

public class EditHtmlAction extends WebAction {
	private static final long serialVersionUID = 1L;
	private String method;
	private String filename;
	private String pagecont;
	

	private List<File> upload = new ArrayList<File>();
	private List<String> uploadContentType = new ArrayList<String>();
	private List<String> uploadFileName = new ArrayList<String>();
	/**
	 * @return the upload
	 */
	public List<File> getUpload() {
		return upload;
	}

	/**
	 * @param upload the upload to set
	 */
	public void setUpload(List<File> upload) {
		this.upload = upload;
	}

	/**
	 * @return the uploadContentType
	 */
	public List<String> getUploadContentType() {
		return uploadContentType;
	}

	/**
	 * @param uploadContentType the uploadContentType to set
	 */
	public void setUploadContentType(List<String> uploadContentType) {
		this.uploadContentType = uploadContentType;
	}

	/**
	 * @return the uploadFileName
	 */
	public List<String> getUploadFileName() {
		return uploadFileName;
	}

	/**
	 * @param uploadFileName the uploadFileName to set
	 */
	public void setUploadFileName(List<String> uploadFileName) {
		this.uploadFileName = uploadFileName;
	}


	/**
	 * @return the pagecont
	 */
	public String getPagecont() {
		return pagecont;
	}

	/**
	 * @param pagecont the pagecont to set
	 */
	public void setPagecont(String pagecont) {
		this.pagecont = pagecont;
	}

	/**
	 * @return the id
	 */
	public String getFilename() {
		return filename;
	}

	/**
	 * @param id the id to set
	 */
	public void setFilename(String filename) {
		this.filename = filename;
	}

	/**
	 * @return the method
	 */
	public String getMethod() {
		return method;
	}

	/**
	 * @param method the method to set
	 */
	public void setMethod(String method) {
		this.method = method;
	}


	@Override
	public String webProcess(WebContext context, Manager manager) {
		if ("save".equals(method)) {
			if(!"-1".equals(filename)){
				if("style.css".equals(filename)){
					//PagesUtil.writeToFile(C.CSS_PATH_WAP2,filename, pagecont);
				}else{
					//PagesUtil.writeToFile(C.JSP_PATH_WAP2,filename, pagecont);
				}
			}
			//context.put("rmsg", C.TEXT.SAVE_SUCCESS);
			return "edit";
		}else if("edit".equals(method)){
			if(!"-1".equals(filename)){
				if("style.css".equals(filename)){
					//context.put("pagecont", PagesUtil.readFile(C.CSS_PATH_WAP2,filename));
				}else{
					//context.put("pagecont", PagesUtil.readFile(C.JSP_PATH_WAP2,filename));
				}
			}
			return "edit";
		}else {
			return "edit";
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.camel.admin.WebAction#getSysLog()
	 */
	@Override
	public String getSysLog() {
		return null;
	}
}
